import requests
import re

domain = "https://dy.dytt8.net/index.htm"
domain_pre = "https://dy.dytt8.net"

resp = requests.get(domain,verify = False)
resp.close()
resp.encoding = "gb2312"
# print(resp.text)

obj1 = re.compile(r"最新影片推荐.*?<ul>(?P<ul>.*?)</ul>",re.S)
obj2 = re.compile(r"<a href='(?P<href>.*?)'",re.S)

result1 = obj1.finditer(resp.text)
child_href_list = []
for it in result1:
    # print(it.group('ul'))
    result2 = obj2.finditer(it.group('ul'))

    for itt in result2:

        # print(domain_pre + itt.group('href'))
        child_href_list.append(domain_pre + itt.group('href'))

print(child_href_list)

obj3 = re.compile(r'<br />◎译　　名(?P<name>.*?)<br />.*?<a target="_blank" href="(?P<magnet>.*?)"><strong>')
name_list = []
magnet_list = []
for href in child_href_list:
    child_resp = requests.get(href,verify = False)
    child_resp.close()
    child_resp.encoding = 'GB2312'

    result3 = obj3.search(child_resp.text)

    name_list.append(result3.group('name'))
    magnet_list.append(result3.group('magnet'))

print(name_list)
print(magnet_list)


pass

